<template>
	<div class="login" :style="{height:height+'px'}">
		<div class="loginForm">
			<div class="head">用户登录</div>
			<el-form ref="form" :model="loginform" label-width="80px">
			  <el-form-item label="账号">
			    <el-input v-model="loginform.username" style="width:240px;" placeholder="账号或者手机号"></el-input>
			  </el-form-item>
			  <el-form-item label="密码">
			    <el-input v-model="loginform.password" style="width:240px;" placeholder="请输入密码" show-password></el-input>
			  </el-form-item>
			  <el-form-item>
			      <el-button type="primary" @click="toLogin">立即登录</el-button>
			    </el-form-item>
			</el-form>
		</div>
		<!-- <el-button type="primary" @click="toLogin">大哥，请登录</el-button> -->
	</div>
	
</template>

<script>
	import { login } from "@/request/api.js"
	export default {
		data(){
			return{
				height:0,
				loginform:{
					username:'13148829008',
					password:'123456'
					
				}
			}
		},
		created() {
			this.height = document.documentElement.clientHeight - 16;
		},
		methods: {
			toLogin(){
				login(this.loginform).then(res => {
					if(res.code == 1){
						this.$gData.setLocal('token',res.token);
						this.$gData.setLocal('userinfo',res.userinfo);
						this.$router.push({name:'dashboard'});
					}else{
						this.$message.error(res.msg);
					}
					
				})
				
			}
		}
	}
</script>
<style lang="scss" scoped>
	.login{
		width:calc(100% - 16px);
		//background:#003e5d;
		background: url(../assets/login.jpg) no-repeat;
		background-size: auto 100%;
		background-position: center;
		margin:8px;
		border-radius: 12px;
		position: relative;
		.loginForm{
			background:#fff;
			width:360px;
			padding:20px 40px;
			position: absolute;
			top:120px;
			right:120px;
			border-radius: 12px;
			.head{
				font-size: 18px;
				line-height: 60px;
				text-align: center;
			}
		}
	}
</style>
